package com.sh.redis.controller;

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;

public class Test {

    public int a = 0;

    public void add(){
        a++;
    }


    private static final String testA = "aaa";
    public static void main(String[] args) throws Exception {
        Test test = new Test();
        Field testAField = test.getClass().getDeclaredField("testA");
        testAField.setAccessible(true);
        Field mo = testAField.getClass().getDeclaredField("modifiers");
        mo.setAccessible(true);
        mo.setInt(testAField, testAField.getModifiers() & ~Modifier.FINAL);
        testAField.set(test, "bbb");
        mo.setInt(testAField, testAField.getModifiers() & ~Modifier.FINAL);
        System.out.println(testA);

    }


}
